package borderPatrol.misc;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.Stack;

import borderPatrol.Data.Move;

public class History implements Serializable {

	private static final long serialVersionUID = 1L;

	public Stack<int[]> sequence;
	public LinkedList<Move> possibleMoves;
	public int sign;
	public float probability;

	@SuppressWarnings("unchecked")
	public History(Stack<int[]> sequence, LinkedList<Move> possibleMoves, int sign) {
		this.sequence = (Stack<int[]>) sequence.clone();
		this.possibleMoves = (LinkedList<Move>) possibleMoves.clone();
		this.sign = sign;
		this.probability = 1;
	}
	
	@SuppressWarnings("unchecked")
	public History(Stack<int[]> sequence, LinkedList<Move> possibleMoves, int sign, float probability) {
		this.sequence = (Stack<int[]>) sequence.clone();
		this.possibleMoves = (LinkedList<Move>) possibleMoves.clone();
		this.sign = sign;
		this.probability = probability;
	}

	public History clone() {
		return new History(sequence, possibleMoves, sign, probability);
	}

	@Override
	public String toString() {

		StringBuilder builder = new StringBuilder();

		builder.append(sign);

		for (int[] item : sequence) {
			if (item[0] != -1) {
				builder.append(".");
				builder.append(item[0]);
				builder.append(item[1]);
			}
		}

		return builder.toString();
	}

}
